package com.vhall.autotest.api_test.service.cloudwise;

import java.util.HashMap;
import java.util.Map;

import org.junit.Assert;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.vhall.autotest.api_test.common.Constant;
import com.vhall.autotest.api_test.common.ConstantCloudwise;
import com.vhall.autotest.api_test.common.Http;
import com.vhall.autotest.api_test.common.Http_new;
import com.vhall.autotest.api_test.common.HttpUtil;
import com.vhall.autotest.api_test.service.code.ICode;
import com.vhall.autotest.api_test.service.code.IWebinarCode;

public class SiteList implements IWebinarCode{
	private static final String SiteListsUrl = Constant.apiDomain + "/v2/site/lists.json";
	/*
	 * 获取网站监控列表
	 * 2016-5-25
	 */
	public static void getSiteLists_success(String access_token,String page,String page_size,String start_date,String end_date) {
		Http http = new Http();
				Map<String, String> param = new HashMap<String, String>();
				param.put("access_token", access_token);
				param.put("page", page);
//				param.put("page_size", page_size);
				param.put("start_date", start_date);
				param.put("end_date", end_date);
				System.out.println("param:" + param);
				Map<String, String> result;
				try {
					result = http.get(SiteListsUrl, param);
					String statusCode = result.get("statusCode");
					String resultText = result.get("resultText");
					System.out.println("statusCode:" + statusCode);
//					System.out.println("resultText:" + resultText);
					Assert.assertNotNull(statusCode);
					Assert.assertNotNull(resultText);
					Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
					JSONArray obj = JSONArray.parseArray(resultText); 
					System.out.println(obj);
//					Assert.assertTrue(obj.containsKey("user_id"));
//					Assert.assertTrue(obj.containsKey("user_email"));
//					Assert.assertTrue(obj.contains("task_name"));
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				

			} 
			

	public static void main(String[] args) {
		SiteList.getSiteLists_success(GetToken.getToken_success(ConstantCloudwise.grant_type, ConstantCloudwise.username,ConstantCloudwise. password,ConstantCloudwise. client_id, ConstantCloudwise.client_secret), "2", "20", "2016-5-26", "2016-5-26");
	}
}

